using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Code_Event
{
    public partial class Form1 : Form
    {

        //通过代码的方式添加事件
        public Form1()
        {
            InitializeComponent();
           

            this.Controls.Add(testButton);
            testButton.Text = "巡天妖捕林季";
            testButton.Location = new Point(200, 200);
            testButton.Size = new Size(100, 40);


         

            //为 testButton 控件的 Click 事件添加了一个事件处理程序 testButton_test
            testButton.Click += new EventHandler(this.testButton_test);
        }


      
        private void testButton_test(object sender, EventArgs e)
        {
            //弹出一个消息框
            MessageBox.Show("七品武夫");
        }
        private Button testButton = new Button();
    }
}

